﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Yeap.Kernel.Security;

namespace Yeap.Kernel.Storage
{
    public class ProfessorRepository :IProfessorRepository
    {
        private readonly UserRepository userRepository = new UserRepository();

        public Professor GetById(int id)
        {
            User idUser = userRepository.GetById(id);

            if (idUser == null)
            {
                return null;
            }

            if (idUser.UserType != (int?)UserTypes.Professor)
            {
                return null;
            }

            return idUser.GetProfessorForm();
        }

        public IEnumerable<Professor> GetAll()
        {
            return userRepository.GetAll().Where(u => u.UserType.HasValue && u.UserType.Value == (int)UserTypes.Professor).Select(u => u.GetProfessorForm());
        }

        public IEnumerable<Professor> Query(System.Linq.Expressions.Expression<Func<Professor, bool>> filter)
        {
            throw new NotImplementedException();
        }
    }
}